<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        
        <el-col :span="8">
          <el-form-item label="菜品单号" prop="FITEMNO">
            <el-input v-model="dataForm.FITEMNO"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="菜品分类">
              <el-select v-model="dataForm.FCATNAME" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="菜品状态">
              <el-select v-model="dataForm.FBILLSTATE" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options3"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="16">
          <el-form-item label="菜品名称"" prop="FITEMNAME">
            <el-input v-model="dataForm.FITEMNAME"   />
          </el-form-item>
        </el-col>

          <el-col :span="8">
          <el-form-item label="菜品规格"" prop="FSPEC">
            <el-input v-model="dataForm.FSPEC"   />
          </el-form-item>
        </el-col>

          <el-col :span="16">
          <el-form-item label="说明"" prop="FMEMO">
            <el-input v-model="dataForm.FMEMO"   />
          </el-form-item>
        </el-col>
        
        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加场地</el-button> -->
            <el-button type="primary" :loading="loading" @click="closePage">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <template>
     <el-tabs v-model="activeName" type="card" @tab-click="handleClick">

      <el-tab-pane label="菜品图片" name="one">
        
        <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
          
          <el-col :span="12">
          <el-upload
            class="avatar-uploader"
            action="https://jsonplaceholder.typicode.com/posts/"
            :show-file-list="false"
            :on-success="handleAvatarSuccess"
            :before-upload="beforeAvatarUpload">
            <img v-if="imageUrl1" :src="imageUrl1" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </el-col>

         </el-form>

      </el-tab-pane>

      <el-tab-pane label="菜品配方" name="second">
        
        <el-table :data="list1" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID"FDATE label="序号" width="85" ></el-table-column>
          <el-table-column prop="FITEMNO" label="食材编号"  width="95"></el-table-column>
          <el-table-column prop="FITEMNAME" label="食材名称"   ></el-table-column>
          <el-table-column prop="FSPEC" label="规格" width="105" ></el-table-column>
          <el-table-column prop="FQTY" label="用量(g)"   ></el-table-column>
          <el-table-column prop="FMEMO" label="备注"></el-table-column>
        </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>

      </el-tab-pane>

      <el-tab-pane label="营养成分" name="four">
        <el-table :data="list2" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID"FDATE label="序号" width="85" ></el-table-column>
          <el-table-column prop="FITEM1" label="标示内容"  width="95"></el-table-column>
          <el-table-column prop="FITEM2" label="每100克"   ></el-table-column>
          <el-table-column prop="FITEM3" label="NRV%" width="105" ></el-table-column>
          <el-table-column prop="FMEMO" label="备注"></el-table-column>
        </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>

    </el-tabs>
    
   </template>

    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        activeName: 'second',
        imageUrl1:require('@/assets/images/me/lims070302.jpeg'),

        title: "新增",
        insertorupdate: true,
        dataForm: {
            FCATNAME: "荤菜",
            FITEMNO: "100001",
            FITEMNAME:"红烧鸡腿",
            FSPEC:"125g",
            FMEMO: "",
            FBILLSTATE:"正常"
        },
        rules: {
          FUSERNUMBER:[
            { required: true, message: '请输入学籍号码', trigger: 'blur' },
          ],
          FUSER: [
            { required: true, message: '请输入申请人员', trigger: 'blur' },
          ],
          FMEMO: [
            { required: true, message: '请输入申请理由', trigger: 'blur' },
          ],
        },
        list1: [{ "FENTRYID":1,
                  "FITEMNO": "100001",
                  "FITEMNAME":"鸡腿",
                  "FSPEC":"80g",
                  "FQTY":50,
                  "FMEMO": ""
                },
                { "FENTRYID":1,
                  "FITEMNO": "100005",
                  "FITEMNAME":"土豆",
                  "FSPEC":"500g",
                  "FQTY":80,
                  "FMEMO": ""
                }],

        list2: [{  "FENTRYID":1,
                    "FITEM1": "能量",
                    "FITEM2":"",
                    "FITEM3": "",
                    "FMEMO": ""
                  },
                  { "FENTRYID":2,
                    "FITEM1": "蛋白质",
                    "FITEM2":"",
                    "FITEM3": "",
                    "FMEMO": ""
                  },
                  { "FENTRYID":3,
                    "FITEM1": "脂肪",
                    "FITEM2":"",
                    "FITEM3": "",
                    "FMEMO": ""
                  },
                  { "FENTRYID":4,
                    "FITEM1": "碳水化合物",
                    "FITEM2":"",
                    "FITEM3": "",
                    "FMEMO": ""
                  },
                  { "FENTRYID":5,
                    "FITEM1": "钠/食盐",
                    "FITEM2":"",
                    "FITEM3": "",
                    "FMEMO": ""
                  }],
        
        loading: false,
        visible: false,

        //所属校区选择数据
        options1: [{
          value: '1',
          label: '新机构'
        }, {
          value: '2',
          label: '改机构'
        }, {
          value: '3',
          label: '老机构'
        }],

        //所属校区选择数据
        options2: [{
          value: '1',
          label: '国资委'
        }, {
          value: '2',
          label: '民营'
        }, {
          value: '3',
          label: '合资'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      closePage(){
        console.log('关闭弹窗dialog');
        this.visible = false;
      },
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shopdate(id) {
        let link = document.createElement('a');
        link.href = 'http://180.166.193.6:90/images/study/acc-01.png';
        link.target = '_blank'; // 在新窗口或新标签页中打开URL
        link.click();
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>